package com.haihui.platform.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * Created by HaiHui on 2017/9/12.
 */
public class JsonUtils {
    public JsonUtils() {
    }
    public static String getJAVABeanJSON(Object o) {
        return getJAVABeanJSON(o, true);
    }

    public static String getJAVABeanJSON(Object o, boolean serializeNull) {
        GsonBuilder builder = (new GsonBuilder()).setDateFormat("yyyy-MM-dd HH:mm:ss");
        if(serializeNull) {
            builder.serializeNulls();
        }
        Gson gson = builder.create();
        String ObjtToJson = gson.toJson(o);
        return ObjtToJson;
    }


}